<?php

namespace App\Controller\api;

use xsl\basic\BaseController;
use xsl\enums\Status;

class Options extends BaseController
{
    public function get($option)
    {
        $array = [];
        switch ($option) {
            case 'dataRange':
                $array = [[
                    'label' => '全部数据',
                    'value' => 1,
                ], [
                    'label' => '本人数据',
                    'value' => 3,
                ]];
                break;
            case 'modules':
                $array = [
                    [
                        'label' => '默认',
                        'value' => 'default',
                    ],
                ];
                $path = BASE_PATH . '/App/Controller/api';
                if (is_dir($path)) {
                    $data = scandir($path);
                    foreach ($data as $value) {
                        if ($value != '.' && $value != '..' && is_dir($path . DIRECTORY_SEPARATOR . $value)) {
                            $array[] = [
                                'label' => $value,
                                'value' => $value,
                            ];
                        }
                    }
                }
                break;
            case "status":
                $array = [
                    [
                        'value' => Status::ENABLE,
                        'label' => '启用',
                    ],
                    [
                        'value' => Status::DISABLE,
                        'label' => '禁用',
                    ]
                ];
                break;
        }
        return $this->success($array);
    }
}